﻿using System;

namespace Commandparser.Common
{

    public class Statement
    {

        public string Name { get; set; }
        public string Argument { get; set; }

        public Statement(string s)
        {
            Name = Middle(s.Remove(s.Length-1,1), "@", "'");
            Argument = Middle(s, "'", "'");
        }

        private string Middle(String str, string startchar, string endchar)
        {
            int strStart = str.IndexOf(startchar, StringComparison.Ordinal) + 1;
            int strEnd = str.LastIndexOf(endchar, StringComparison.Ordinal);
            return str.Substring(strStart, strEnd - strStart);
        }

    }
}
